package com.cqw.auth.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-07-15 17:05
 * @Description:
 */
@RestController(value = "test1")
@RequestMapping("/auth")
public class TestController {


    @GetMapping("/info")
    public Object info(Principal principal) {
        return principal;
    }


    @GetMapping("/admin")
    @PreAuthorize("hasAnyAuthority('admin')")
    public String admin() {
        return "admin";
    }

    @GetMapping("/test")
    @PreAuthorize("hasAuthority('test')")
    public String test() {
        return "test";
    }


}
